package com.wjh.www.controller;

import com.wjh.www.annotation.spring.Autowired;
import com.wjh.www.annotation.spring.Component;
import com.wjh.www.annotation.springmvc.RequestBody;
import com.wjh.www.annotation.springmvc.RequestMapping;
import com.wjh.www.annotation.springmvc.RequestParam;
import com.wjh.www.entity.bo.StudentCourseBo;
import com.wjh.www.entity.dto.CommonResult;
import com.wjh.www.entity.po.Course;
import com.wjh.www.entity.vo.ExcelVo;
import com.wjh.www.service.impl.CourseServiceImpl;

import javax.servlet.annotation.WebServlet;
import java.util.List;

/**
 * 课程相关接口
 *
 * @author wjh
 * @date 2021/9/11 13:53
 * @Package com.wjh.anyview.controller
 */
@WebServlet("/anyview/course/*")
@Component
public class CourseController extends DispatcherController {
    @Autowired
    private CourseServiceImpl courseService;

    @RequestMapping("/addCourse")
    CommonResult<?> addCourse(@RequestBody Course course) {
        return courseService.addCourse(course);
    }

    @RequestMapping("/updateCourseById")
    CommonResult<?> updateCourseById(@RequestBody Course course) {
        return courseService.updateCourseById(course);
    }

    @RequestMapping("/deleteCourseById")
    CommonResult<?> deleteCourseById(@RequestParam("courseId") Long courseId) {
        return courseService.deleteCourseById(courseId);
    }

    @RequestMapping("/queryCourseByGrade")
    CommonResult<List<Course>> queryCourseByGrade(@RequestParam("grade") Integer grade) {
        return courseService.queryCourseByGrade(grade);
    }

    @RequestMapping("/choiceCourse")
    CommonResult<?> choiceCourse(@RequestBody StudentCourseBo studentCourseBo) {
        return courseService.choiceCourse(studentCourseBo);
    }

    @RequestMapping("/queryPreCourseByStudentId")
    CommonResult<List<Course>> queryPreCourseByStudentId(@RequestParam("studentId") Long studentId) {
        return courseService.queryPreCourseByStudentId(studentId);
    }

    @RequestMapping("/affirmCourse")
    CommonResult<?> affirmCourse(@RequestBody StudentCourseBo studentCourseBo) {
        return courseService.affirmCourse(studentCourseBo);
    }

    @RequestMapping("/cancelCourse")
    CommonResult<?> cancelCourse(@RequestBody StudentCourseBo studentCourseBo) {
        return courseService.cancelCourse(studentCourseBo);
    }

    @RequestMapping("/listCourseInExcel")
    CommonResult<ExcelVo> listCourseInExcel(@RequestParam("studentId") Long studentId) {
        return courseService.listCourseInExcel(studentId);
    }

    @RequestMapping("/queryAllCourse")
    CommonResult<List<Course>> queryAllCourse(@RequestParam("adminId") Long adminId) {
        return courseService.queryAllCourse();
    }
}
